<template>
  <div class="tab-bar-item ignore" @click="tabItemClick">
    <slot v-if="!isActive" name="item-icon"></slot>
    <slot v-else name="item-icon-active"></slot>
    <div :style="activeStyle">
      <slot name="item-text"></slot>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    path: String,
    active_color: {
      type: String,
      default: 'red',
    },
  },
  data() {
    return {}
  },
  computed: {
    isActive() {
      return this.$route.path.indexOf(this.path) !== -1
    },
    activeStyle() {
      return this.isActive ? { color: this.active_color } : {}
    },
  },
  methods: {
    tabItemClick() {
      this.$router.push(this.path)
    },
  },
}
</script>

<style lang="less">
.tab-bar-item {
  flex: 1;
  text-align: center;
  height: 49px;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  img {
    width: 20px;
    height: 20px;
  }
}
</style>
